package a66weding.com.jiehuntong.activity.home.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.activity.CategorySearchActivity;
import a66weding.com.jiehuntong.adapter.MyBaseAdapter;
import a66weding.com.jiehuntong.dao.record.RecordBean;

/**
 * Created by admin on 2016/8/9.
 */
public class ForSearchLvAdapter extends MyBaseAdapter {

    public ForSearchLvAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup viewGroup) {
        ViewHolder vh;
        if (convertView==null){
            vh = new ViewHolder();
            convertView = View.inflate(context, R.layout.item_lv_adapter,null);
            vh.tv = (TextView) convertView.findViewById(R.id.item_lv_tv);
            convertView.setTag(vh);
        }else{
            vh = (ViewHolder) convertView.getTag();
        }
        RecordBean bean = (RecordBean) data.get(position);
        vh.tv.setText(bean.getKeywords());
        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, CategorySearchActivity.class);
                intent.putExtra("searchinfo",((RecordBean) data.get(position)).getKeywords());
                context.startActivity(intent);
            }
        });
        return convertView;
    }
    public class ViewHolder{
        TextView tv;
    }

}
